﻿<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>教务管理系统 - 管理员首页</title>
    <link href="${pageContext.request.contextPath}/resources/bootstrap5/css/bootstrap.min.css" rel="stylesheet">
    <!-- 使用国内稳定的BootCDN Bootstrap Icons -->
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <!-- 备用CDN链接 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <style>
        body {
            font-family: "Microsoft YaHei", sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }

        .header {
            background-color: #1976d2;
            color: white;
            padding: 10px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
        }
        
        .header-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .header h2 {
            margin: 0;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
        }

        .header h2 img {
            height: 36px;
            margin-right: 10px;
        }

        .header-logo {
            width: 36px;
            height: 36px;
            margin-right: 12px;
        }

        .header-title {
            font-size: 1.4rem;
            font-weight: bold;
            letter-spacing: 1px;
        }

        .header-nav {
            margin-left: 32px;
            font-size: 1rem;
        }

        .header-nav a {
            color: #fff;
            text-decoration: none;
            margin-right: 16px;
            opacity: 0.85;
        }

        .header-nav a.active, .header-nav a:hover {
            opacity: 1;
            font-weight: bold;
        }

        .header .breadcrumb {
            margin: 0;
            background: transparent;
            color: white;
        }

        .header .breadcrumb a {
            color: rgba(255,255,255,0.8);
            text-decoration: none;
        }

        .header .breadcrumb a:hover {
            color: white;
        }

        .header .breadcrumb-item.active {
            color: white;
        }

        .header .breadcrumb-item+.breadcrumb-item::before {
            color: rgba(255,255,255,0.6);
        }

        /* 侧边栏样式 */
        .sidebar {
            position: fixed;
            top: 56px;
            left: 0;
            bottom: 0;
            width: 250px;
            background-color: white;
            box-shadow: 2px 0 5px rgba(0,0,0,0.1);
            overflow-y: auto;
            z-index: 100;
            padding-top: 20px;
        }

        .sidebar-menu {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .sidebar-menu > li {
            margin-bottom: 5px;
        }

        .sidebar-menu > li > a {
            display: flex;
            align-items: center;
            padding: 12px 20px;
            color: #333;
            text-decoration: none;
            transition: all 0.3s;
            border-left: 3px solid transparent;
        }

        .sidebar-menu > li > a:hover {
            background-color: #f0f0f0;
            border-left-color: #1976d2;
        }

        .sidebar-menu > li > a.active {
            background-color: #e3f2fd;
            border-left-color: #1976d2;
            color: #1976d2;
        }

        .sidebar-menu > li > a i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 1.1rem;
        }

        .sidebar-submenu {
            list-style: none;
            padding-left: 53px;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }

        .sidebar-menu > li.open .sidebar-submenu {
            max-height: 500px;
        }

        .sidebar-submenu > li > a {
            display: block;
            padding: 8px 0;
            color: #666;
            text-decoration: none;
            transition: all 0.3s;
        }

        .sidebar-submenu > li > a:hover {
            color: #1976d2;
        }

        .sidebar-submenu > li > a.active {
            color: #1976d2;
            font-weight: 500;
        }

        /* 内容区样式 */
        .content {
            margin-left: 250px;
            padding: 76px 20px 20px;
        }
        
        /* 用户下拉菜单样式 */
        .header-user {
            display: flex;
            align-items: center;
            position: relative;
        }
        .header-user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            margin-right: 8px;
            object-fit: cover;
            background: #fff;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .header-user-avatar:hover {
            transform: scale(1.1);
        }
        .header-user-name {
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            min-width: 160px;
            z-index: 1001;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s ease;
            margin-top: 8px;
        }
        .user-dropdown.show {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        .user-dropdown::before {
            content: '';
            position: absolute;
            top: -6px;
            right: 16px;
            width: 12px;
            height: 12px;
            background: #fff;
            transform: rotate(45deg);
            border-left: 1px solid rgba(0,0,0,0.08);
            border-top: 1px solid rgba(0,0,0,0.08);
        }
        .user-dropdown a {
            display: block;
            padding: 10px 16px;
            color: #333;
            text-decoration: none;
            font-size: 0.9rem;
            transition: background-color 0.2s;
        }
        .user-dropdown a:hover {
            background-color: #f8f9fa;
        }
        .user-dropdown a:first-child {
            border-radius: 8px 8px 0 0;
        }
        .user-dropdown a:last-child {
            border-radius: 0 0 8px 8px;
            border-top: 1px solid #eee;
            color: #dc3545;
        }
        .user-dropdown a:last-child:hover {
            background-color: #fff5f5;
        }

        /* 统计卡片样式 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        }

        .stat-icon {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
            margin-bottom: 16px;
        }

        .stat-icon.users { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
        .stat-icon.teachers { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
        .stat-icon.students { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
        .stat-icon.courses { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }

        .stat-number {
            font-size: 2rem;
            font-weight: bold;
            color: #2c3e50;
            margin-bottom: 8px;
        }

        .stat-label {
            color: #7f8c8d;
            font-size: 0.9rem;
        }

        .chart-container {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            margin-bottom: 30px;
        }

        .chart-title {
            font-size: 1.2rem;
            font-weight: 600;
            color: #2c3e50;
            margin-bottom: 20px;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s;
            }

            .content {
                margin-left: 0;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        /* 教务通知样式 */
        .notification-list {
            max-height: 400px;
            overflow-y: auto;
        }

        .notification-item {
            padding: 16px 0;
            border-bottom: 1px solid #f0f0f0;
            transition: background-color 0.2s;
        }

        .notification-item:last-child {
            border-bottom: none;
        }

        .notification-item:hover {
            background-color: #f8f9fa;
            border-radius: 8px;
            margin: 0 -12px;
            padding: 16px 12px;
        }

        .notification-content h6.notification-title {
            color: #2c3e50;
            font-weight: 600;
            margin-bottom: 6px;
            font-size: 1rem;
        }

        .notification-text {
            color: #666;
            font-size: 0.9rem;
            margin-bottom: 8px;
            line-height: 1.4;
        }

        .notification-meta .date {
            color: #999;
            font-size: 0.8rem;
        }

        /* 考试安排样式 */
        .exam-list {
            max-height: 400px;
            overflow-y: auto;
        }

        .exam-item {
            padding: 16px 0;
            border-bottom: 1px solid #f0f0f0;
            transition: background-color 0.2s;
        }

        .exam-item:last-child {
            border-bottom: none;
        }

        .exam-item:hover {
            background-color: #f8f9fa;
            border-radius: 8px;
            margin: 0 -12px;
            padding: 16px 12px;
        }

        .exam-content h6.exam-title {
            color: #2c3e50;
            font-weight: 600;
            margin-bottom: 6px;
            font-size: 1rem;
        }

        .exam-description {
            color: #666;
            font-size: 0.9rem;
            margin-bottom: 8px;
            line-height: 1.4;
        }

        .exam-meta .exam-time {
            color: #007bff;
            font-size: 0.9rem;
            font-weight: 500;
        }

        /* 滚动条样式 */
        .notification-list::-webkit-scrollbar,
        .exam-list::-webkit-scrollbar {
            width: 6px;
        }

        .notification-list::-webkit-scrollbar-track,
        .exam-list::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 3px;
        }

        .notification-list::-webkit-scrollbar-thumb,
        .exam-list::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }

        .notification-list::-webkit-scrollbar-thumb:hover,
        .exam-list::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }

        .user-dropdown-item {
            display: flex;
            align-items: center;
            padding: 12px 16px;
            color: #333;
            text-decoration: none;
            transition: background 0.2s;
            border-bottom: 1px solid #f0f0f0;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }

        .user-dropdown-item:last-child {
            border-bottom: none;
        }

        .user-dropdown-item:hover {
            background: #f8f9fa;
            color: #2196f3;
        }

        .user-dropdown-item i {
            margin-right: 8px;
            width: 16px;
            text-align: center;
        }
    </style>
</head>
<body>

<!-- 头部导航 -->
<div class="header">
    <div class="header-left">
        <img src="${pageContext.request.contextPath}/resources/images/logo.png" alt="Logo" class="header-logo">
        <span class="header-title">教务管理系统</span>
        <div class="header-nav">
            <a href="${pageContext.request.contextPath}/admin/home" class="active">系统首页</a>
        </div>
    </div>

    <!-- 用户名下拉菜单 -->
    <div class="header-user" id="userDropdownContainer">
        <img src="${pageContext.request.contextPath}/resources/images/baimao.png" class="header-user-avatar" alt="用户名头像" id="userAvatar">
        <span class="header-user-name" id="userName">
            <c:choose>
                <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.realName}">
                    ${sessionScope.loggedInUser.realName}
                </c:when>
                <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.username}">
                    ${sessionScope.loggedInUser.username}
                </c:when>
                <c:otherwise>
                    系统管理员
                </c:otherwise>
            </c:choose>
        </span>
        <div class="user-dropdown" id="userDropdown">
            <a href="#" class="user-dropdown-item" id="profileBtn">
                <i class="bi bi-person-circle"></i>
                个人中心
            </a>
            <a href="${pageContext.request.contextPath}/user/logout" class="user-dropdown-item">
                <i class="bi bi-box-arrow-right"></i>
                退出系统
            </a>
        </div>
    </div>
</div>

<!-- 侧边栏 -->
<div class="sidebar">
    <ul class="sidebar-menu">
        <li>
            <a href="${pageContext.request.contextPath}/admin/home" class="active">
                <i class="bi bi-house-door"></i> 系统首页
            </a>
        </li>
        <li>
            <a href="#" class="has-submenu">
                <i class="bi bi-megaphone"></i> 信息公告
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/admin/notifications/academic">教学通知</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/notifications/exam">考试安排</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/notifications/classroom">教室安排</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu">
                <i class="bi bi-building"></i> 行政管理
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/admin/college">学院信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/major">专业信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/class">班级信息</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu">
                <i class="bi bi-book"></i> 教学管理
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/admin/course">课程信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/course-selection">选课管理</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/score">成绩管理</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/online">网上评教</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu">
                <i class="bi bi-calendar3"></i> 教务管理
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/admin/leave">请假管理</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/homework">作业提交</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/attendance">考勤信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/online">网上评教</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu">
                <i class="bi bi-person"></i> 用户管理
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/admin/admin">管理员信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/teacher">教师信息</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/student">学生信息</a></li>
            </ul>
        </li>
        <li>
            <a href="${pageContext.request.contextPath}/user/logout">
                <i class="bi bi-box-arrow-right"></i> 退出系统
            </a>
        </li>
    </ul>
</div>

<!-- 主要内容区域 -->
<div class="content">
    <div class="stats-grid">
        <!-- 管理员统计 -->
        <div class="stat-card">
            <div class="stat-icon users">
                <i class="bi bi-person-gear"></i>
            </div>
            <div class="stat-number">${adminCount}</div>
            <div class="stat-label">管理员总数</div>
        </div>

        <!-- 教师统计 -->
        <div class="stat-card">
            <div class="stat-icon teachers">
                <i class="bi bi-person-workspace"></i>
            </div>
            <div class="stat-number">${teacherCount}</div>
            <div class="stat-label">教师总数</div>
        </div>

        <!-- 学生统计 -->
        <div class="stat-card">
            <div class="stat-icon students">
                <i class="bi bi-people-fill"></i>
            </div>
            <div class="stat-number">${studentCount}</div>
            <div class="stat-label">学生总数</div>
        </div>

        <!-- 课程统计 -->
        <div class="stat-card">
            <div class="stat-icon courses">
                <i class="bi bi-journal-bookmarks"></i>
            </div>
            <div class="stat-number">${courseCount}</div>
            <div class="stat-label">课程总数</div>
        </div>
    </div>

    <!-- 教务通知 -->
    <div class="row mb-4">
        <div class="col-lg-6">
            <div class="chart-container">
                <h3 class="chart-title">
                    <i class="bi bi-bell me-2"></i>
                    教务通知
                </h3>
                <div class="notification-list">
                    <c:choose>
                        <c:when test="${not empty academicNotifications}">
                            <c:forEach var="notification" items="${academicNotifications}">
                                <div class="notification-item">
                                    <div class="notification-content">
                                        <h6 class="notification-title">${notification.title}</h6>
                                        <p class="notification-text">${notification.content}</p>
                                        <div class="notification-meta">
                                            <span class="date">
                                                <c:choose>
                                                    <c:when test="${fn:length(notification.createTime) > 10}">
                                                        ${fn:substring(notification.createTime, 0, 10)}
                                                    </c:when>
                                                    <c:otherwise>
                                                        ${notification.createTime}
                                                    </c:otherwise>
                                                </c:choose>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                            <div class="text-center py-4 text-muted">
                                <i class="bi bi-inbox display-4"></i>
                                <p class="mt-2">暂无教务通知</p>
                            </div>
                        </c:otherwise>
                    </c:choose>
                </div>
            </div>
        </div>
        
        <div class="col-lg-6">
            <div class="chart-container">
                <h3 class="chart-title">
                    <i class="bi bi-calendar-event me-2"></i>
                    考试安排
                </h3>
                <div class="exam-list">
                    <c:choose>
                        <c:when test="${not empty examNotifications}">
                            <c:forEach var="exam" items="${examNotifications}">
                                <div class="exam-item">
                                    <div class="exam-content">
                                        <h6 class="exam-title">${exam.title}</h6>
                                        <p class="exam-description">${exam.content}</p>
                                        <div class="exam-meta">
                                            <span class="exam-time">
                                                <c:choose>
                                                    <c:when test="${fn:length(exam.createTime) > 16}">
                                                        ${fn:substring(exam.createTime, 0, 16)}
                                                    </c:when>
                                                    <c:otherwise>
                                                        ${exam.createTime}
                                                    </c:otherwise>
                                                </c:choose>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                            <div class="text-center py-4 text-muted">
                                <i class="bi bi-calendar-x display-4"></i>
                                <p class="mt-2">暂无考试安排</p>
                            </div>
                        </c:otherwise>
                    </c:choose>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/resources/bootstrap5/jquery-3.6.0.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bootstrap5/js/bootstrap.bundle.min.js"></script>

<script>
    $(document).ready(function() {
        // 用户名下拉菜单功能
        let userDropdownTimeout;

        $('#userDropdownContainer').hover(
            function() {
                clearTimeout(userDropdownTimeout);
                $('#userDropdown').addClass('show');
            },
            function() {
                userDropdownTimeout = setTimeout(function() {
                    $('#userDropdown').removeClass('show');
                }, 300);
            }
        );

        // 点击头像或用户名也可以显示下拉菜单
        $('#userAvatar, #userName').click(function(e) {
            e.preventDefault();
            $('#userDropdown').toggleClass('show');
        });

        // 点击其他地方隐藏下拉菜单
        $(document).click(function(e) {
            if (!$(e.target).closest('#userDropdownContainer').length) {
                $('#userDropdown').removeClass('show');
            }
        });

        // 个人中心功能
        $('#profileBtn').click(function(e) {
            e.preventDefault();
            $('#userDropdown').removeClass('show');
            loadUserProfile();
            $('#profileModal').modal('show');
        });

        // 加载用户个人信息
        function loadUserProfile() {
            $.ajax({
                url: '${pageContext.request.contextPath}/user/profile',
                type: 'GET',
                success: function(response) {
                    if (response.success) {
                        const user = response.user;
                        $('#profileUsername').val(user.username);
                        $('#profileRealName').val(user.realName || '');

                        // 设置角色显示
                        let roleText = '';
                        switch(user.role) {
                            case 1: roleText = '管理员'; break;
                            case 2: roleText = '教师'; break;
                            case 3: roleText = '学生'; break;
                            default: roleText = '未知'; break;
                        }
                        $('#profileRole').val(roleText);
                    } else {
                        alert('获取用户个人信息失败: ' + response.message);
                    }
                },
                error: function() {
                    alert('获取用户个人信息失败，请重试');
                }
            });
        }

        // 更新个人信息
        $('#updateProfileBtn').click(function() {
            const realName = $('#profileRealName').val().trim();
            if (!realName) {
                alert('请输入真实姓名');
                return;
            }

            $.ajax({
                url: '${pageContext.request.contextPath}/user/updateProfile',
                type: 'POST',
                data: {
                    realName: realName
                },
                success: function(response) {
                    if (response.success) {
                        alert('个人信息更新成功');
                        // 更新页面显示的用户名
                        $('#userName').text(realName);
                        $('#profileModal').modal('hide');
                        // 刷新页面以更新所有显示的用户名
                        setTimeout(function() {
                            location.reload();
                        }, 1000);
                    } else {
                        alert('更新失败: ' + response.message);
                    }
                },
                error: function() {
                    alert('更新失败，请重试');
                }
            });
        });

        // 修改密码
        $('#changePasswordBtn').click(function() {
            const oldPassword = $('#oldPassword').val();
            const newPassword = $('#newPassword').val();
            const confirmPassword = $('#confirmPassword').val();

            if (!oldPassword || !newPassword || !confirmPassword) {
                alert('请填写完整的密码信息');
                return;
            }

            if (newPassword.length < 6) {
                alert('新密码长度不能少于6位');
                return;
            }

            if (newPassword !== confirmPassword) {
                alert('新密码和确认密码不一致');
                return;
            }

            $.ajax({
                url: '${pageContext.request.contextPath}/user/changePassword',
                type: 'POST',
                data: {
                    oldPassword: oldPassword,
                    newPassword: newPassword,
                    confirmPassword: confirmPassword
                },
                success: function(response) {
                    if (response.success) {
                        alert('密码修改成功');
                        $('#passwordForm')[0].reset();
                        $('#profileModal').modal('hide');
                    } else {
                        alert('修改失败: ' + response.message);
                    }
                },
                error: function() {
                    alert('修改失败，请重试');
                }
            });
        });

        // 模态框关闭时重置表单
        $('#profileModal').on('hidden.bs.modal', function() {
            $('#profileForm')[0].reset();
            $('#passwordForm')[0].reset();
            // 切换回个人信息标签
            $('#profile-info-tab').tab('show');
        });
    });
</script>

<script>
    // 用户下拉菜单交互
    document.addEventListener('DOMContentLoaded', function() {
        const userDropdownContainer = document.getElementById('userDropdownContainer');
        const userDropdown = document.getElementById('userDropdown');
        
        if (userDropdownContainer && userDropdown) {
            userDropdownContainer.addEventListener('click', function(e) {
                e.stopPropagation();
                userDropdown.classList.toggle('show');
            });
            
            document.addEventListener('click', function() {
                userDropdown.classList.remove('show');
            });
        }

        // 侧边栏子菜单 - 修改为支持新的菜单结构
        document.querySelectorAll('.sidebar-menu .has-submenu').forEach(function(item) {
            item.addEventListener('click', function(e) {
                e.preventDefault();
                e.stopPropagation();
                
                // 获取父级li元素
                const parentLi = this.closest('li');
                
                // 切换open类
                parentLi.classList.toggle('open');
                
                // 关闭其他打开的菜单
                document.querySelectorAll('.sidebar-menu > li.open').forEach(function(openItem) {
                    if (openItem !== parentLi) {
                        openItem.classList.remove('open');
                    }
                });
            });
        });
    });
</script>

<!-- 个人中心模态框 -->
<div class="modal fade" id="profileModal" tabindex="-1" aria-labelledby="profileModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="profileModalLabel">个人中心</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <ul class="nav nav-tabs" id="profileTabs" role="tablist">
                    <li class="nav-item">
                        <button class="nav-link active" id="profile-info-tab" data-bs-toggle="tab" data-bs-target="#profile-info" type="button" role="tab" aria-controls="profile-info" aria-selected="true">
                            <i class="bi bi-person"></i> 个人信息
                        </button>
                    </li>
                    <li class="nav-item">
                        <button class="nav-link" id="change-password-tab" data-bs-toggle="tab" data-bs-target="#change-password" type="button" role="tab" aria-controls="change-password" aria-selected="false">
                            <i class="bi bi-key"></i> 修改密码
                        </button>
                    </li>
                </ul>
                <div class="tab-content" id="profileTabContent">
                    <div class="tab-pane fade show active" id="profile-info" role="tabpanel" aria-labelledby="profile-info-tab">
                        <form id="profileForm" class="mt-3">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="profileUsername" class="form-label">用户名</label>
                                        <input type="text" class="form-control" id="profileUsername" readonly>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="profileRole" class="form-label">角色</label>
                                        <input type="text" class="form-control" id="profileRole" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="mb-3">
                                <label for="profileRealName" class="form-label">真实姓名</label>
                                <input type="text" class="form-control" id="profileRealName" required>
                            </div>
                            <div class="d-grid gap-2">
                                <button type="button" class="btn btn-primary" id="updateProfileBtn">
                                    <i class="bi bi-check-circle"></i> 更新信息
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="tab-pane fade" id="change-password" role="tabpanel" aria-labelledby="change-password-tab">
                        <form id="passwordForm" class="mt-3">
                            <div class="mb-3">
                                <label for="oldPassword" class="form-label">原密码</label>
                                <input type="password" class="form-control" id="oldPassword" required>
                            </div>
                            <div class="mb-3">
                                <label for="newPassword" class="form-label">新密码</label>
                                <input type="password" class="form-control" id="newPassword" required minlength="6">
                                <div class="form-text">密码长度至少6位</div>
                            </div>
                            <div class="mb-3">
                                <label for="confirmPassword" class="form-label">确认新密码</label>
                                <input type="password" class="form-control" id="confirmPassword" required>
                            </div>
                            <div class="d-grid gap-2">
                                <button type="button" class="btn btn-warning" id="changePasswordBtn">
                                    <i class="bi bi-key"></i> 修改密码
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>

